﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.YAML.FlowFormatList`1
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Collections;
using System.Collections.Generic;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Serialization;


namespace DnProcessSimulateCommands.ExportToRTR.YAML;

public class FlowFormatList<T> : 
  IList<T>,
  ICollection<T>,
  IEnumerable<T>,
  IEnumerable,
  IYamlConvertible,
  IIgnoreObjFlowForamt
{
  private List<T> list_ = new List<T>();

  public FlowFormatList(List<T> value) => this.list_ = value;

  public FlowFormatList(T value) => this.list_.Add(value);

  public FlowFormatList()
  {
  }

  T IList<T>.this[int index]
  {
    get => this.list_[index];
    set => this.list_[index] = value;
  }

  public int Count => this.list_.Count;

  public T this[int i]
  {
    get => this.list_[i];
    set => this.list_[i] = value;
  }

  int ICollection<T>.Count => this.list_.Count;

  bool ICollection<T>.IsReadOnly => false;

  public void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer)
  {
    this.list_ = new List<T>((IEnumerable<T>) nestedObjectDeserializer.Invoke(typeof (List<T>)));
  }

  public void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer)
  {
    emitter.Emit((ParsingEvent) new SequenceStart(AnchorName.op_Implicit((string) null), TagName.op_Implicit((string) null), false, (SequenceStyle) 2));
    foreach (T obj in this.list_)
      nestedObjectSerializer.Invoke((object) obj, (Type) null);
    emitter.Emit((ParsingEvent) new SequenceEnd());
  }

  public void Add(T item) => this.list_.Add(item);

  public void AddRange(IEnumerable<T> collection) => this.list_.AddRange(collection);

  void ICollection<T>.Clear() => this.list_.Clear();

  bool ICollection<T>.Contains(T item) => this.list_.Contains(item);

  void ICollection<T>.CopyTo(T[] array, int arrayIndex) => this.list_.CopyTo(array, arrayIndex);

  IEnumerator<T> IEnumerable<T>.GetEnumerator() => (IEnumerator<T>) this.list_.GetEnumerator();

  IEnumerator IEnumerable.GetEnumerator() => (IEnumerator) this.list_.GetEnumerator();

  int IList<T>.IndexOf(T item) => this.list_.IndexOf(item);

  void IList<T>.Insert(int index, T item) => this.list_.Insert(index, item);

  bool ICollection<T>.Remove(T item) => this.list_.Remove(item);

  void IList<T>.RemoveAt(int index) => this.list_.RemoveAt(index);

  public bool IsEmpty => this.list_.Count == 0;
}
